package net.xdclass.controller;

import net.xdclass.domain.Video;
import net.xdclass.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @description: 视频控制器
 * @author: Yz
 * @create: 2020-11-10 13:58
 **/
@RestController
@RequestMapping("/api/v1/video")
public class VideoController {

    @Autowired
    private VideoService videoService;

    @GetMapping("find_by_id")
    public Object findById(int videoId, HttpServletRequest request){
        Video video = videoService.findById(videoId);
        //方便查看请求哪台服务器
        video.setServerInfo(request.getServerName()+":"+request.getServerPort());
        return video;
    }

    @PostMapping("save")
    public int findById(@RequestBody Video video){
        System.out.println(video.getTitle());
        return 1;
    }

}
